package com.jzo2o.foundations.controller.consumer;


import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.service.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 首页服务查询接口")
public class FirstPageServeController {

    @Resource
    private HomeService homeService;
    @GetMapping("/firstPageServeList")
    @ApiOperation("首页服务列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataTypeClass =  Long.class)
    })
    public List<ServeCategoryResDTO> serverCategory(@RequestParam("regionId") Long regionId){

        List<ServeCategoryResDTO> serveCategoryResDTOList = homeService.queryServeCategoryListByRegionId(regionId);
        return serveCategoryResDTOList;
    }

    @GetMapping("/serveTypeList")
    @ApiOperation("服务类型列表")
    @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataTypeClass =  Long.class)
    public List<ServeAggregationTypeSimpleResDTO> serveTypeList(@RequestParam(name = "regionId") Long regionId){
        List<ServeAggregationTypeSimpleResDTO> serveTypeList = homeService.queryServeTypeListByRegionId(regionId);
        return serveTypeList;
    }

    @GetMapping("/hotServeList")
    @ApiOperation("热门服务列表")
    public List<ServeAggregationSimpleResDTO> hotServeList(@RequestParam("regionId") Long regionId){
        List<ServeAggregationSimpleResDTO> hotServeList = homeService.queryHotServeList(regionId);
        return hotServeList;
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询服务详情")
    public ServeAggregationSimpleResDTO findById(@PathVariable("id") Long id){
        ServeAggregationSimpleResDTO serveAggregationSimpleResDTO = homeService.findById(id);
        return serveAggregationSimpleResDTO;
    }

}
